<%-- 
    Document   : index
    Created on : 18/06/2011, 11:21:20
    Author     : flavioam
--%>

<%@page import="br.unesp.demac.bcc.soo.bean.Pessoa"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js" type="text/javascript"></script>
<link rel="stylesheet" href="http://static.jquery.com/ui/css/base.css" type="text/css" media="all" />
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/ui-lightness/jquery-ui.css" type="text/css" media="all" />
<link rel="stylesheet" href="http://static.jquery.com/ui/css/demo-docs-theme/ui.theme.css" type="text/css" media="all" />


<script>
    
    $(document).ready(function(){

        $("#mytabs").tabs(); 
        $("#dataInicio").datepicker({ dateFormat: 'dd/mm/yy'});
        $("#dataFim").datepicker({ dateFormat: 'dd/mm/yy'});
    });
    
    function relatorioFilmesAlugados(){
        
        $("#relatorioFilmesAlugados").html('<img src="icons/carregando.gif"></img>');
        
        $.post("relatorios", { relatorio: "filmesAlugados"},													   
        function(data){
                        
            //if the record was updated
            if (data.status == 'ok'){										

                $("#relatorioFilmesAlugados").html(data.table);																						
            }
            else{
                alert(data.message);
            }
        }, "json");
    }
    
    function relatorioHistorico(){
        
        $("#relatorioHistorico").html('<img src="icons/carregando.gif"></img>');
        
        $.post("relatorios", { relatorio: "historico"},													   
        function(data){
                        
            //if the record was updated
            if (data.status == 'ok'){										

                $("#relatorioHistorico").html(data.table);																						
            }
            else{
                alert(data.message);
            }
        }, "json");
    }
    
    function relatorioRanking(){
        
        $("#relatorioRanking").html('<img src="icons/carregando.gif"></img>');
        
        if($("#dataInicio").val() == '' || $("#dataFim").val() == '' || $("#quantFilmes").val() == ''){
         
            alert("Data Início, Data Final e Quantidade de Filmes são campos obrigatórios!")
        }else{
        
            $.post("relatorios", { relatorio: "ranking", dataInicio: $("#dataInicio").val(), dataFim: $("#dataFim").val(), quantFilmes: $("#quantFilmes").val()},													   
            function(data){
                        
                //if the record was updated
                if (data.status == 'ok'){										

                    $("#relatorioRanking").html(data.table);																						
                }
                else{
                    alert(data.message);
                }
            }, "json");
        }
    }
    
</script>

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <%

            Pessoa p = (Pessoa) session.getAttribute("pessoa");
        %>
        <title>Locadora Online</title>
    </head>
    <body>

        <h1 style="padding-top: 30px;padding-left: 40px;color: white;">Locadora On line</h1>

        <div id="mytabs">
            <ul>
                <li><a href="#fragment-1"><span>Meus Dados</span></a></li>
                <li><a href="#fragment-2"><span>Meus Filmes Alugados</span></a></li>
                <li><a href="#fragment-3"><span>Meu Histórico de Aluguéis</span></a></li>
                <li><a href="#fragment-4"><span>Filmes Mais Alugados</span></a></li>
            </ul>
            <div id="fragment-1">

                <fieldset><legend>Cliente</legend>
                    <table>
                        <tr>
                            <td>Nome:</td>
                            <td><%=p.getNome()%></td>
                        </tr>
                        <tr>
                            <td>Cpf:</td>
                            <td><%=p.getCpf()%></td>
                        </tr>
                    </table>
                </fieldset>

                <fieldset><legend>Contato</legend>                
                    <table>
                        <tr>
                            <td>Email: </td>
                            <td><%=p.getContato().getEmail()%></td>
                        </tr>
                        <tr>
                            <td>Telefone Residencial:</td>
                            <td><%=p.getContato().getTelefoneResidencial()%></td>
                        </tr>
                        <tr>
                            <td>Telefone Comercial:</td>
                            <td><%=p.getContato().getTelefoneComercial()%></td>

                        </tr>
                        <tr>
                            <td>Telefone Celular:</td>
                            <td><%=p.getContato().getTelefoneCelular()%></td>
                        </tr>
                    </table>                    
                </fieldset>

                <fieldset><legend>Endereco</legend>                
                    <table>
                        <tr>
                            <td>Endereco: </td>
                            <td><%=p.getEndereco().getEndereco()%></td>
                        </tr>
                        <tr>
                            <td>Cidade:</td>
                            <td><%=p.getEndereco().getCidade()%></td>
                        </tr>
                        <tr>
                            <td>Estado:</td>
                            <td><%=p.getEndereco().getEstado()%></td>
                        </tr>
                    </table>                    
                </fieldset>

            </div>
            <div id="fragment-2">

                <div align="center" width="100%"><input type="button" onClick="relatorioFilmesAlugados();" value="Gerar Relatorio"></input></div>

                <div width="100%" align="center" id="relatorioFilmesAlugados"></div>

            </div>            
            <div id="fragment-3">

                <div align="center" width="100%"><input type="button" onClick="relatorioHistorico();" value="Gerar Relatorio"></input></div>

                <div width="100%" align="center" id="relatorioHistorico"></div>

            </div>
            <div id="fragment-4">

                <fieldset><legend>Filtros</legend>

                    <table>
                        <tr>
                            <td>Data Início:</td>
                            <td><input type="text" readonly="true" id="dataInicio" style="width: 85px"></input></td>
                            <td></td>
                        </tr>
                        <tr>
                            <td>Data Fim:</td>
                            <td><input type="text" readonly="true" id="dataFim" style="width: 85px"></input></td>
                            <td></td>
                        </tr>     
                        <tr>
                            <td>Quantidade de Filmes(0 = todos):</td>
                            <td><input type="text" id="quantFilmes" style="width: 40px" value="0"></input></td>
                            <td><input type="button" onClick="relatorioRanking();" value="Gerar Relatorio"></input></td>
                        </tr>  
                    </table>
                </fieldset>

                <br>

                <div width="100%" align="center" id="relatorioRanking"></div>

            </div>
        </div>

    </body>    
</html>


